package GUI;

import GUI.añadido.AñadirCliente;
import GUI.ver.VerPresupuesto;
import GUI.modelosTablas.AlmacenDefaultTableModel;
import GUI.modelosTablas.ClientesSearchBox;
import GUI.modelosTablas.OcupacionSearchModel;
import GUI.modelosTablas.PeticionesDefaultTableModel;
import GUI.modelosTablas.SearchBoxModel;
import GUI.modelosTablas.ServiciosPrestadosDefaultTableModel;
import GUI.modelosTablas.TareasDefaultTableModel;
import base.Aviso;
import base.Cliente;
import base.Equipo;
import base.Estado;
import base.Peticion;
import base.Presupuesto;
import base.Servicio;
import base.Tarea;
import base.Empleado;
import base.Telefono;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.Timer;
import javax.swing.table.DefaultTableModel;
import negocio.Usuario;
import negocio.bd.BDAlmacenEquipos;
import negocio.bd.BDAviso;
import negocio.bd.BDClientes;
import negocio.bd.BDPeticiones;
import negocio.bd.BDPresupuestos;
import negocio.bd.BDServicios;
import negocio.bd.BDTareas;
import negocio.bd.BDTecnicos;
import utiles.ConversorFecha;

/**
 *
 * @author Efren
 */
public class VistaRecepcionista extends javax.swing.JFrame {
    Usuario usuario;
    private boolean isFirst;
    private static boolean isFirst2;
    private Cliente clienteActual;
    private long idTarea;
    private boolean isFirst3;
    private int filaEditada;
    private boolean visualizandoRecogida;
    private Equipo[] equiposADevolver;
    private long idTareaAviso;
    private Aviso a;

    /**
     * Creates new form VistaRecepcionista
     */
    public VistaRecepcionista(Usuario user) {
        //Recuperamos los datos del usuario actual.
        usuario = user;
        initComponents();
        setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/img/ico.png")));
        this.dialogoTarea.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/img/ico.png")));
        this.dialogoREquipos.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/img/ico.png")));
        this.dialogoNuevaPeticion.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/img/ico.png")));
        this.verAvisoFinalizado.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/img/ico.png")));
        this.verAvisos.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/img/ico.png")));
        //Centrar en pantalla la ventana
        this.setLocationRelativeTo(null);
        //Obtener el listado de avisos.
        actualizarListadoAvisos();
        //Obtencion de modelos de datos para la tabla de peticiones y la de tareas.
        this.tablaPeticiones.setModel(new PeticionesDefaultTableModel(false, BDPeticiones.buscar(BDPeticiones.buscarPorFecha, ConversorFecha.getFechaFormatoBD(new GregorianCalendar()))));
        this.tablaTareas.setModel(new TareasDefaultTableModel(false,BDTareas.obtenerTodos()));
        Timer timer = new Timer (60000, new ActionListener () 
{ 
    
    @Override
    public void actionPerformed(ActionEvent e) 
    { 
        tablaPeticiones.setModel(new PeticionesDefaultTableModel(false, BDPeticiones.buscar(BDPeticiones.buscarPorFecha, ConversorFecha.getFechaFormatoBD(new GregorianCalendar()))));
        tablaTareas.setModel(new TareasDefaultTableModel(false,BDTareas.obtenerTodos()));
        actualizarListadoAvisos();
     } 
     }); 

timer.setRepeats(true);
timer.start();
        //Evitar que las columnas se puedan arrastrar y cambiar de orden.
        tablaPeticiones.getTableHeader().setReorderingAllowed(false);
        tablaTareas.getTableHeader().setReorderingAllowed(false);
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);
        //Si el usuario no es ni un recepcionista ni un administrador mostrar falta de permisos y salir.
        if (user.getPermisos() != Usuario.RECEPCIONISTA && user.getPermisos() != Usuario.ADMINISTRADOR){
            Dialogos.mostrarDialogoFaltanPermisos();
            this.setVisible(false);
        }
    }
    public void actualizarListadoAvisos(){
        this.listaAvisos.setModel(new AvisosDefaultListModel());
    }
    public void  mostrarDialogoNuevaPeticion(){
        dialogoNuevaPeticion.pack();
        dialogoNuevaPeticion.setVisible(true);
        //Variables para saber si el combo se ha desplegado por primera vez
        isFirst = true;
        isFirst2 = true;
        dialogoNuevaPeticion.setLocationRelativeTo(null);
        //Modelos por defecto para combos y tablas.
        this.listaTelefonos.setModel(new DefaultListModel());
        this.comboServicios.setModel(new SearchBoxModel(comboServicios, BDServicios.obtenerTodos()));
        comboClientes.setModel(new ClientesSearchBox(comboClientes, BDClientes.obtenerClientes()));
        this.tablaServiciosPresupuesto.setModel(new ServiciosPrestadosDefaultTableModel(false));
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jLayeredPane2 = new javax.swing.JLayeredPane();
        panelPeticiones1 = new javax.swing.JPanel();
        panelTareas1 = new javax.swing.JPanel();
        dialogoNuevaPeticion = new javax.swing.JDialog();
        jPanel2 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        lblNombre = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        lblDireccion = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        listaTelefonos = new javax.swing.JList();
        jLabel5 = new javax.swing.JLabel();
        comboClientes = new javax.swing.JComboBox();
        btnEditarCliente = new javax.swing.JButton();
        btnAñadirNuevoCliente = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        txtDescripcion = new javax.swing.JTextArea();
        jPanel6 = new javax.swing.JPanel();
        comboServicios = new javax.swing.JComboBox();
        btnAñadirPresupuesto = new javax.swing.JButton();
        unidades = new javax.swing.JSpinner();
        jScrollPane6 = new javax.swing.JScrollPane();
        tablaServiciosPresupuesto = new javax.swing.JTable();
        jLabel6 = new javax.swing.JLabel();
        lblTotal = new javax.swing.JLabel();
        btnAceptarNPeticion = new javax.swing.JButton();
        btnCancelarNPeticion = new javax.swing.JButton();
        popupPresupuesto = new javax.swing.JPopupMenu();
        mnuBorrarFila = new javax.swing.JMenuItem();
        mnuBorrarUnidades = new javax.swing.JMenuItem();
        jDialog1 = new javax.swing.JDialog();
        jPanel7 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jSpinner1 = new javax.swing.JSpinner();
        dialogoREquipos = new javax.swing.JDialog();
        jPanel8 = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtNumeroSerie = new javax.swing.JTextField();
        txtMarca = new javax.swing.JTextField();
        txtModelo = new javax.swing.JTextField();
        jPanel11 = new javax.swing.JPanel();
        btnAñadirEquipo = new javax.swing.JButton();
        btnEditarEquipo = new javax.swing.JButton();
        btnQuitarEquipo = new javax.swing.JButton();
        jPanel12 = new javax.swing.JPanel();
        btnAceptarRecogida = new javax.swing.JButton();
        btnCancelarRecogida = new javax.swing.JButton();
        jPanel13 = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        tablaEquipos = new javax.swing.JTable();
        jPanel14 = new javax.swing.JPanel();
        comboTecnicos = new javax.swing.JComboBox();
        dialogoTarea = new javax.swing.JDialog();
        jPanel17 = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        lblDireccion3 = new javax.swing.JLabel();
        jScrollPane10 = new javax.swing.JScrollPane();
        listaTelefonos3 = new javax.swing.JList();
        jLabel17 = new javax.swing.JLabel();
        lblNombre3 = new javax.swing.JLabel();
        jPanel18 = new javax.swing.JPanel();
        jScrollPane11 = new javax.swing.JScrollPane();
        tablaEquiposDevolver = new javax.swing.JTable();
        btnDevolver = new javax.swing.JButton();
        jPanel19 = new javax.swing.JPanel();
        jScrollPane12 = new javax.swing.JScrollPane();
        tablaServiciosPrestados = new javax.swing.JTable();
        btnFactura = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        total = new javax.swing.JLabel();
        jPanel20 = new javax.swing.JPanel();
        btnCerrar = new javax.swing.JButton();
        verAvisos = new javax.swing.JDialog();
        jPanel15 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        lblNombreClienteAviso = new javax.swing.JLabel();
        lblTelefonoClienteAviso = new javax.swing.JLabel();
        jPanel16 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        tablaPreAntiguo = new javax.swing.JTable();
        jPanel21 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        tablaPreNuevo = new javax.swing.JTable();
        jScrollPane13 = new javax.swing.JScrollPane();
        txtDesAviso = new javax.swing.JTextArea();
        jLabel14 = new javax.swing.JLabel();
        jPanel22 = new javax.swing.JPanel();
        btnAceptarModificaciones = new javax.swing.JButton();
        btnCancelarModificaciones = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        verAvisoFinalizado = new javax.swing.JDialog();
        jPanel25 = new javax.swing.JPanel();
        btnNotificado = new javax.swing.JButton();
        btnNoNotificado = new javax.swing.JButton();
        jPanel23 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        lblNombreClienteAviso1 = new javax.swing.JLabel();
        lblTelefonoClienteAviso1 = new javax.swing.JLabel();
        jPanel24 = new javax.swing.JPanel();
        jButton3 = new javax.swing.JButton();
        jScrollPane14 = new javax.swing.JScrollPane();
        txtDesAviso1 = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtBuscar = new javax.swing.JTextField();
        panelAvisos = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        listaAvisos = new javax.swing.JList();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        panelPeticiones = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablaPeticiones = new javax.swing.JTable();
        panelTareas = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tablaTareas = new javax.swing.JTable();
        jButton4 = new javax.swing.JButton();

        panelPeticiones1.setBorder(javax.swing.BorderFactory.createTitledBorder("Peticiones"));

        javax.swing.GroupLayout panelPeticiones1Layout = new javax.swing.GroupLayout(panelPeticiones1);
        panelPeticiones1.setLayout(panelPeticiones1Layout);
        panelPeticiones1Layout.setHorizontalGroup(
            panelPeticiones1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 448, Short.MAX_VALUE)
        );
        panelPeticiones1Layout.setVerticalGroup(
            panelPeticiones1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 312, Short.MAX_VALUE)
        );

        panelPeticiones1.setBounds(0, 0, 460, 335);
        jLayeredPane2.add(panelPeticiones1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        panelTareas1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tareas"));

        javax.swing.GroupLayout panelTareas1Layout = new javax.swing.GroupLayout(panelTareas1);
        panelTareas1.setLayout(panelTareas1Layout);
        panelTareas1Layout.setHorizontalGroup(
            panelTareas1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 448, Short.MAX_VALUE)
        );
        panelTareas1Layout.setVerticalGroup(
            panelTareas1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 312, Short.MAX_VALUE)
        );

        panelTareas1.setBounds(0, 0, 460, 335);
        jLayeredPane2.add(panelTareas1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLayeredPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 338, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLayeredPane2)
                .addContainerGap())
        );

        dialogoNuevaPeticion.setTitle("Gestionaitor 2000 - Nueva Petición");
        dialogoNuevaPeticion.setResizable(false);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Selección Cliente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setText("Nombre:");

        lblNombre.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lblNombre.setText(" ");
        lblNombre.setToolTipText("");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel3.setText("Dirección:");

        lblDireccion.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lblDireccion.setText(" ");
        lblDireccion.setToolTipText("");

        listaTelefonos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        listaTelefonos.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        listaTelefonos.setToolTipText("");
        jScrollPane4.setViewportView(listaTelefonos);

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel5.setText("Telefonos:");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblNombre, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblDireccion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane4)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(lblNombre))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(lblDireccion))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)))
        );

        comboClientes.setEditable(true);
        comboClientes.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        comboClientes.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        comboClientes.setToolTipText("");
        comboClientes.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
            public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
                comboClientesPopupMenuWillBecomeVisible(evt);
            }
        });
        comboClientes.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboClientesItemStateChanged(evt);
            }
        });

        btnEditarCliente.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnEditarCliente.setText("Editar Datos");
        btnEditarCliente.setToolTipText("");
        btnEditarCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarClienteActionPerformed(evt);
            }
        });

        btnAñadirNuevoCliente.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnAñadirNuevoCliente.setText("Nuevo cliente");
        btnAñadirNuevoCliente.setToolTipText("");
        btnAñadirNuevoCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAñadirNuevoClienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnEditarCliente)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(comboClientes, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnAñadirNuevoCliente)))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboClientes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAñadirNuevoCliente))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnEditarCliente)
                .addGap(4, 4, 4))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Descripción de petición", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        txtDescripcion.setColumns(20);
        txtDescripcion.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtDescripcion.setLineWrap(true);
        txtDescripcion.setRows(5);
        txtDescripcion.setToolTipText("");
        jScrollPane5.setViewportView(txtDescripcion);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Presupuesto", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        comboServicios.setEditable(true);
        comboServicios.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        comboServicios.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        comboServicios.setToolTipText("");
        comboServicios.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
            public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
                comboServiciosPopupMenuWillBecomeVisible(evt);
            }
        });

        btnAñadirPresupuesto.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnAñadirPresupuesto.setText("Añadir");
        btnAñadirPresupuesto.setToolTipText("");
        btnAñadirPresupuesto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAñadirPresupuestoActionPerformed(evt);
            }
        });

        unidades.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        unidades.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));
        unidades.setToolTipText("");

        tablaServiciosPresupuesto.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tablaServiciosPresupuesto.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tablaServiciosPresupuesto.setToolTipText("");
        tablaServiciosPresupuesto.setComponentPopupMenu(popupPresupuesto);
        tablaServiciosPresupuesto.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jScrollPane6.setViewportView(tablaServiciosPresupuesto);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel6.setText("Total:");

        lblTotal.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lblTotal.setText(" ");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(250, Short.MAX_VALUE))
            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(comboServicios, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(unidades, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnAñadirPresupuesto))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboServicios, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAñadirPresupuesto)
                    .addComponent(unidades, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(lblTotal))
                .addContainerGap())
        );

        btnAceptarNPeticion.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnAceptarNPeticion.setText("Aceptar");
        btnAceptarNPeticion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarNPeticionActionPerformed(evt);
            }
        });

        btnCancelarNPeticion.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnCancelarNPeticion.setText("Cancelar");
        btnCancelarNPeticion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarNPeticionActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dialogoNuevaPeticionLayout = new javax.swing.GroupLayout(dialogoNuevaPeticion.getContentPane());
        dialogoNuevaPeticion.getContentPane().setLayout(dialogoNuevaPeticionLayout);
        dialogoNuevaPeticionLayout.setHorizontalGroup(
            dialogoNuevaPeticionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoNuevaPeticionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dialogoNuevaPeticionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(dialogoNuevaPeticionLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btnAceptarNPeticion))
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(dialogoNuevaPeticionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(dialogoNuevaPeticionLayout.createSequentialGroup()
                        .addComponent(btnCancelarNPeticion)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        dialogoNuevaPeticionLayout.setVerticalGroup(
            dialogoNuevaPeticionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoNuevaPeticionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dialogoNuevaPeticionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(dialogoNuevaPeticionLayout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(dialogoNuevaPeticionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAceptarNPeticion)
                    .addComponent(btnCancelarNPeticion))
                .addContainerGap())
        );

        popupPresupuesto.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
            public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
                popupPresupuestoPopupMenuWillBecomeVisible(evt);
            }
        });

        mnuBorrarFila.setText("Borrar fila");
        mnuBorrarFila.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuBorrarFilaActionPerformed(evt);
            }
        });
        popupPresupuesto.add(mnuBorrarFila);

        mnuBorrarUnidades.setText("Quitar unidades");
        mnuBorrarUnidades.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuBorrarUnidadesActionPerformed(evt);
            }
        });
        popupPresupuesto.add(mnuBorrarUnidades);

        jDialog1.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jDialog1.setTitle("Seleccion número");

        jButton2.setText("Cancelar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton1.setText("Aceptar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addContainerGap())
        );

        javax.swing.GroupLayout jDialog1Layout = new javax.swing.GroupLayout(jDialog1.getContentPane());
        jDialog1.getContentPane().setLayout(jDialog1Layout);
        jDialog1Layout.setHorizontalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jDialog1Layout.setVerticalGroup(
            jDialog1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDialog1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        dialogoREquipos.setTitle("Gestionaitor 2000 - Recogida Equipo");

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Equipo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel7.setText("Modelo:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setText("Número de serie:");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel9.setText("Marca:");

        txtNumeroSerie.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        txtMarca.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        txtModelo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        btnAñadirEquipo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnAñadirEquipo.setText("Añadir");
        btnAñadirEquipo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAñadirEquipoActionPerformed(evt);
            }
        });
        jPanel11.add(btnAñadirEquipo);

        btnEditarEquipo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnEditarEquipo.setText("Editar");
        btnEditarEquipo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditarEquipoActionPerformed(evt);
            }
        });
        jPanel11.add(btnEditarEquipo);

        btnQuitarEquipo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnQuitarEquipo.setText("Quitar");
        btnQuitarEquipo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnQuitarEquipoActionPerformed(evt);
            }
        });
        jPanel11.add(btnQuitarEquipo);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel10Layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(txtNumeroSerie, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel10Layout.createSequentialGroup()
                                    .addComponent(jLabel9)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(txtMarca))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel10Layout.createSequentialGroup()
                                    .addComponent(jLabel7)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(txtModelo, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 61, Short.MAX_VALUE))
                    .addComponent(jPanel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(txtNumeroSerie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(txtMarca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtModelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 11, Short.MAX_VALUE))
        );

        btnAceptarRecogida.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnAceptarRecogida.setText("Aceptar");
        btnAceptarRecogida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarRecogidaActionPerformed(evt);
            }
        });
        jPanel12.add(btnAceptarRecogida);

        btnCancelarRecogida.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnCancelarRecogida.setText("Cancelar");
        btnCancelarRecogida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarRecogidaActionPerformed(evt);
            }
        });
        jPanel12.add(btnCancelarRecogida);

        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Equipos a recoger", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        tablaEquipos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tablaEquipos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane7.setViewportView(tablaEquipos);

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Técnico encargado", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        comboTecnicos.setEditable(true);
        comboTecnicos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        comboTecnicos.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
            public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
            }
            public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
                comboTecnicosPopupMenuWillBecomeVisible(evt);
            }
        });

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addGap(51, 51, 51)
                .addComponent(comboTecnicos, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(comboTecnicos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(16, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel13, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jPanel14, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout dialogoREquiposLayout = new javax.swing.GroupLayout(dialogoREquipos.getContentPane());
        dialogoREquipos.getContentPane().setLayout(dialogoREquiposLayout);
        dialogoREquiposLayout.setHorizontalGroup(
            dialogoREquiposLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoREquiposLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        dialogoREquiposLayout.setVerticalGroup(
            dialogoREquiposLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoREquiposLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        dialogoTarea.setTitle("Gestionaitor 2000 - Detalle Tarea finalizada");

        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos cliente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jLabel15.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel15.setText("Nombre:");

        jLabel16.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel16.setText("Dirección:");

        lblDireccion3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lblDireccion3.setText(" ");

        listaTelefonos3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        listaTelefonos3.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane10.setViewportView(listaTelefonos3);

        jLabel17.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel17.setText("Telefonos:");

        lblNombre3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lblNombre3.setText(" ");

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblNombre3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(4, 4, 4))
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblDireccion3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane10)))
                .addContainerGap())
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(lblNombre3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(lblDireccion3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)))
        );

        jPanel18.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Equipos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        tablaEquiposDevolver.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tablaEquiposDevolver.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane11.setViewportView(tablaEquiposDevolver);

        btnDevolver.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnDevolver.setText("Devolver");
        btnDevolver.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDevolverActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane11)
                    .addGroup(jPanel18Layout.createSequentialGroup()
                        .addComponent(btnDevolver)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane11, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnDevolver, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel19.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Servicios Prestados", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        tablaServiciosPrestados.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tablaServiciosPrestados.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane12.setViewportView(tablaServiciosPrestados);

        btnFactura.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnFactura.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/document-print-5.png"))); // NOI18N
        btnFactura.setText("Imprimir Factura");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel4.setText("Total:");

        total.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

        javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19);
        jPanel19.setLayout(jPanel19Layout);
        jPanel19Layout.setHorizontalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel19Layout.createSequentialGroup()
                        .addComponent(btnFactura)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(total, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel19Layout.setVerticalGroup(
            jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel19Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(total, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnFactura)
                        .addComponent(jLabel4)))
                .addContainerGap())
        );

        btnCerrar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnCerrar.setText("Cerrar");
        btnCerrar.setMinimumSize(new java.awt.Dimension(150, 25));
        btnCerrar.setPreferredSize(new java.awt.Dimension(150, 25));
        btnCerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCerrarActionPerformed(evt);
            }
        });
        jPanel20.add(btnCerrar);

        javax.swing.GroupLayout dialogoTareaLayout = new javax.swing.GroupLayout(dialogoTarea.getContentPane());
        dialogoTarea.getContentPane().setLayout(dialogoTareaLayout);
        dialogoTareaLayout.setHorizontalGroup(
            dialogoTareaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoTareaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dialogoTareaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(dialogoTareaLayout.createSequentialGroup()
                        .addGroup(dialogoTareaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        dialogoTareaLayout.setVerticalGroup(
            dialogoTareaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoTareaLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(dialogoTareaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel19, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, dialogoTareaLayout.createSequentialGroup()
                        .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        verAvisos.setTitle("Gestioneitor 2000 - Detalle de Aviso");

        jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información del cliente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel10.setText("Nombre:");

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel11.setText("Telefonos:");

        lblNombreClienteAviso.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lblNombreClienteAviso.setText("jLabel12");

        lblTelefonoClienteAviso.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lblTelefonoClienteAviso.setText("jLabel13");

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblNombreClienteAviso, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel15Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblTelefonoClienteAviso, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(60, Short.MAX_VALUE))
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel15Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(lblNombreClienteAviso))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(lblTelefonoClienteAviso))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Presupuesto antiguo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        tablaPreAntiguo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tablaPreAntiguo.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane8.setViewportView(tablaPreAntiguo);

        javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
        jPanel16.setLayout(jPanel16Layout);
        jPanel16Layout.setHorizontalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel16Layout.setVerticalGroup(
            jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel21.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Nuevo presupuesto", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        tablaPreNuevo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tablaPreNuevo.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane9.setViewportView(tablaPreNuevo);

        txtDesAviso.setEditable(false);
        txtDesAviso.setColumns(20);
        txtDesAviso.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtDesAviso.setLineWrap(true);
        txtDesAviso.setRows(5);
        jScrollPane13.setViewportView(txtDesAviso);

        jLabel14.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel14.setText("Descripción cambios:");

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane13, javax.swing.GroupLayout.DEFAULT_SIZE, 361, Short.MAX_VALUE)
                    .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanel21Layout.createSequentialGroup()
                        .addComponent(jLabel14)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel21Layout.createSequentialGroup()
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane13, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addContainerGap())
        );

        btnAceptarModificaciones.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnAceptarModificaciones.setText("Aceptar modificaciones");
        btnAceptarModificaciones.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarModificacionesActionPerformed(evt);
            }
        });
        jPanel22.add(btnAceptarModificaciones);

        btnCancelarModificaciones.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnCancelarModificaciones.setText("Cancelar modificaciones");
        btnCancelarModificaciones.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarModificacionesActionPerformed(evt);
            }
        });
        jPanel22.add(btnCancelarModificaciones);

        jButton5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton5.setText("No notificado");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jPanel22.add(jButton5);

        javax.swing.GroupLayout verAvisosLayout = new javax.swing.GroupLayout(verAvisos.getContentPane());
        verAvisos.getContentPane().setLayout(verAvisosLayout);
        verAvisosLayout.setHorizontalGroup(
            verAvisosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(verAvisosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(verAvisosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(verAvisosLayout.createSequentialGroup()
                        .addGroup(verAvisosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        verAvisosLayout.setVerticalGroup(
            verAvisosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(verAvisosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(verAvisosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel21, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(verAvisosLayout.createSequentialGroup()
                        .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel16, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(12, 12, 12))
        );

        verAvisoFinalizado.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        verAvisoFinalizado.setTitle("Gestioneitor 2000 - Detalle de aviso");

        btnNotificado.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnNotificado.setText("Notificado");
        btnNotificado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNotificadoActionPerformed(evt);
            }
        });
        jPanel25.add(btnNotificado);

        btnNoNotificado.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btnNoNotificado.setText("No notificado");
        btnNoNotificado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNoNotificadoActionPerformed(evt);
            }
        });
        jPanel25.add(btnNoNotificado);

        jPanel23.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información del cliente", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel12.setText("Nombre:");

        jLabel13.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel13.setText("Telefonos:");

        lblNombreClienteAviso1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lblNombreClienteAviso1.setText("jLabel12");

        lblTelefonoClienteAviso1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        lblTelefonoClienteAviso1.setText("jLabel13");

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblNombreClienteAviso1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblTelefonoClienteAviso1, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 39, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(lblNombreClienteAviso1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(lblTelefonoClienteAviso1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel24.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Información de tarea", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jButton3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton3.setText("Ver Presupuesto");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        txtDesAviso1.setColumns(20);
        txtDesAviso1.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
        txtDesAviso1.setLineWrap(true);
        txtDesAviso1.setRows(5);
        jScrollPane14.setViewportView(txtDesAviso1);

        javax.swing.GroupLayout jPanel24Layout = new javax.swing.GroupLayout(jPanel24);
        jPanel24.setLayout(jPanel24Layout);
        jPanel24Layout.setHorizontalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel24Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel24Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jScrollPane14))
                    .addGroup(jPanel24Layout.createSequentialGroup()
                        .addComponent(jButton3)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel24Layout.setVerticalGroup(
            jPanel24Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel24Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout verAvisoFinalizadoLayout = new javax.swing.GroupLayout(verAvisoFinalizado.getContentPane());
        verAvisoFinalizado.getContentPane().setLayout(verAvisoFinalizadoLayout);
        verAvisoFinalizadoLayout.setHorizontalGroup(
            verAvisoFinalizadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, verAvisoFinalizadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(verAvisoFinalizadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        verAvisoFinalizadoLayout.setVerticalGroup(
            verAvisoFinalizadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(verAvisoFinalizadoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel23, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel24, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel25, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Menu Principal - Recepcionista");
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("Buscar");

        txtBuscar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        txtBuscar.setToolTipText("Cuadro para buscar tanto peticiones y tareas por dni de cliente.");
        txtBuscar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtBuscarKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        panelAvisos.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Avisos Pendientes", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        listaAvisos.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        listaAvisos.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        listaAvisos.setToolTipText("Listado de avisos pendientes de notificar al cliente.");
        listaAvisos.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                listaAvisosMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(listaAvisos);

        javax.swing.GroupLayout panelAvisosLayout = new javax.swing.GroupLayout(panelAvisos);
        panelAvisos.setLayout(panelAvisosLayout);
        panelAvisosLayout.setHorizontalGroup(
            panelAvisosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAvisosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelAvisosLayout.setVerticalGroup(
            panelAvisosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAvisosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1)
                .addContainerGap())
        );

        jTabbedPane1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        tablaPeticiones.setAutoCreateRowSorter(true);
        tablaPeticiones.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tablaPeticiones.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tablaPeticiones.setToolTipText("Tabla que muestra las peticiones, las más actuales primero.");
        tablaPeticiones.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        tablaPeticiones.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaPeticionesMouseClicked(evt);
            }
        });
        tablaPeticiones.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                tablaPeticionesComponentResized(evt);
            }
        });
        jScrollPane2.setViewportView(tablaPeticiones);

        javax.swing.GroupLayout panelPeticionesLayout = new javax.swing.GroupLayout(panelPeticiones);
        panelPeticiones.setLayout(panelPeticionesLayout);
        panelPeticionesLayout.setHorizontalGroup(
            panelPeticionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelPeticionesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelPeticionesLayout.setVerticalGroup(
            panelPeticionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelPeticionesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                .addContainerGap())
        );

        jScrollPane2.getAccessibleContext().setAccessibleName("");

        jTabbedPane1.addTab("Peticiones", panelPeticiones);

        tablaTareas.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        tablaTareas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tablaTareas.setToolTipText("Tabla que muestra las tareas, las más actuales primero.");
        tablaTareas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablaTareasMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tablaTareas);

        javax.swing.GroupLayout panelTareasLayout = new javax.swing.GroupLayout(panelTareas);
        panelTareas.setLayout(panelTareasLayout);
        panelTareasLayout.setHorizontalGroup(
            panelTareasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTareasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelTareasLayout.setVerticalGroup(
            panelTareasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelTareasLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Tareas", panelTareas);

        jTabbedPane1.setSelectedComponent(panelPeticiones);

        jButton4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/dialog-more.png"))); // NOI18N
        jButton4.setText("Nueva Petición");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton4)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jTabbedPane1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(panelAvisos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addGap(19, 19, 19)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(panelAvisos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jTabbedPane1))
                .addContainerGap())
        );

        jTabbedPane1.getAccessibleContext().setAccessibleName("tab");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
        // TODO add your handling code here:
    }//GEN-LAST:event_formComponentResized

    private void tablaPeticionesComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_tablaPeticionesComponentResized
        // TODO add your handling code here:
    }//GEN-LAST:event_tablaPeticionesComponentResized

    private void comboServiciosPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_comboServiciosPopupMenuWillBecomeVisible
        //Si es la primera vez que se despliega el combo, cargar datos.
        if (isFirst && (comboServicios.getModel() != null)) {
            isFirst = false;
            ((SearchBoxModel)comboServicios.getModel()).updateModel("");
        }
    }//GEN-LAST:event_comboServiciosPopupMenuWillBecomeVisible

    private void comboClientesPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_comboClientesPopupMenuWillBecomeVisible
        //Si es la primera vez que se despliega el combo, cargar datos.
        if (isFirst2 && (comboClientes.getModel() != null)) {
            isFirst2 = false;
            ((ClientesSearchBox)comboClientes.getModel()).updateModel("");
        }
    }//GEN-LAST:event_comboClientesPopupMenuWillBecomeVisible

    private void comboClientesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboClientesItemStateChanged
        //Cuando se seleccione un elemento del combo rellenar la interfaz con los datos obtenidos.
        if (evt.getStateChange()== ItemEvent.SELECTED){
            String dni = (String) evt.getItem();
            clienteActual = BDClientes.obtenerCliente(dni);
            lblNombre.setText(clienteActual.getNombre() + " "+ (clienteActual.getPrimerApellido()==null?" ":clienteActual.getPrimerApellido()) + " " + (clienteActual.getSegundoApellido()==null?" ":clienteActual.getSegundoApellido()));
            lblDireccion.setText(clienteActual.getDireccion()==null?"Sin dirección":clienteActual.getDireccion().toString());
            this.listaTelefonos.setModel(new TelefonosDefaultListModel(clienteActual.getTelefonos()));
        }
    }//GEN-LAST:event_comboClientesItemStateChanged

    private void btnAñadirNuevoClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAñadirNuevoClienteActionPerformed
        //Muestra el formulario Añadir cliente
        AñadirCliente v = new AñadirCliente(null);
        v.setLocationRelativeTo(null);
        v.setVisible(true);
    }//GEN-LAST:event_btnAñadirNuevoClienteActionPerformed
    public static void actualizarComboClientes(){
            comboClientes.setModel(new ClientesSearchBox(comboClientes, BDClientes.obtenerClientes()));
            isFirst2 = true;
    }
    private void btnAñadirPresupuestoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAñadirPresupuestoActionPerformed
        // variable para determinar si existe el servicio en la tabla
        boolean existe = false;
        String combo = ((String) this.comboServicios.getSelectedItem());
        if (combo != null){
        ServiciosPrestadosDefaultTableModel modelo = (ServiciosPrestadosDefaultTableModel)this.tablaServiciosPresupuesto.getModel();
        Servicio serv =BDServicios.buscar(BDServicios.buscarPorNombre,combo, BDServicios.ASC, false)[0];
        for (int i = 0; i < modelo.getRowCount();i++){
            if (serv.getNombre().equalsIgnoreCase((String)modelo.getValueAt(i, 0))){
                modelo.setValueAt((((int)modelo.getValueAt(i, 1))+(int)unidades.getValue()), i, 1);
                existe=true;
            }
        }
        if (!existe){
            serv.setUnidades((int)unidades.getValue());
            modelo.añadirFila(serv);
        }
        this.tablaServiciosPresupuesto.setModel(modelo);
        this.lblTotal.setText(modelo.calcularCoste() + " €");
        this.unidades.setValue(1);
        }
    }//GEN-LAST:event_btnAñadirPresupuestoActionPerformed

    private void mnuBorrarFilaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuBorrarFilaActionPerformed
        // TODO add your handling code here:
        int fila = this.tablaServiciosPresupuesto.getSelectedRow();
        if (fila != -1){
            ServiciosPrestadosDefaultTableModel m = ((ServiciosPrestadosDefaultTableModel)tablaServiciosPresupuesto.getModel());
            m.removeRow(fila);
            tablaServiciosPresupuesto.setModel(m);
            this.lblTotal.setText(((ServiciosPrestadosDefaultTableModel)this.tablaServiciosPresupuesto.getModel()).calcularCoste() + " €");
        }
    }//GEN-LAST:event_mnuBorrarFilaActionPerformed

    private void mnuBorrarUnidadesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuBorrarUnidadesActionPerformed
        // TODO add your handling code here:
        int fila = this.tablaServiciosPresupuesto.getSelectedRow();
        if (fila != -1){
        jDialog1.pack();
        jDialog1.setLocationRelativeTo(null);
        jDialog1.setVisible(true);
        }
    }//GEN-LAST:event_mnuBorrarUnidadesActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        jDialog1.setVisible(false);
        jDialog1.dispose();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        
        int valueAt = (int) this.tablaServiciosPresupuesto.getValueAt(this.tablaServiciosPresupuesto.getSelectedRow(), 1);
        int menos = (int) jSpinner1.getValue();
        int res = valueAt - menos;
        if (res <= 0){
            int fila = this.tablaServiciosPresupuesto.getSelectedRow();
            if (fila != -1){
                ServiciosPrestadosDefaultTableModel m = ((ServiciosPrestadosDefaultTableModel)tablaServiciosPresupuesto.getModel());
                m.removeRow(fila);
                tablaServiciosPresupuesto.setModel(m);
            }
        } else {
            this.tablaServiciosPresupuesto.setValueAt(res, tablaServiciosPresupuesto.getSelectedRow(), 1);
        }
        this.lblTotal.setText(((ServiciosPrestadosDefaultTableModel)this.tablaServiciosPresupuesto.getModel()).calcularCoste() + " €");
        jDialog1.setVisible(false);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void popupPresupuestoPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_popupPresupuestoPopupMenuWillBecomeVisible
        // TODO add your handling code here:
        if (this.tablaServiciosPresupuesto.getSelectedRow() == -1){
           popupPresupuesto.setVisible(false);
        }
    }//GEN-LAST:event_popupPresupuestoPopupMenuWillBecomeVisible

    private void btnCancelarNPeticionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarNPeticionActionPerformed
        // TODO add your handling code here:
        this.dialogoNuevaPeticion.setVisible(false);
        this.dialogoNuevaPeticion.dispose();
    }//GEN-LAST:event_btnCancelarNPeticionActionPerformed

    private void btnAceptarNPeticionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarNPeticionActionPerformed
       if (txtDescripcion.getText()!= null){
           Peticion pet = new Peticion();
           pet.setCliente(clienteActual);
           pet.setDescripcion(txtDescripcion.getText());
           pet.setFecha(new GregorianCalendar());
           if (this.tablaServiciosPresupuesto.getRowCount() != 0){
               if ((Dialogos.mostrarDialogoConfirmacion("¿Esta seguro de que desea guardar la petición?")) == JOptionPane.YES_OPTION){
                   boolean insertar = BDPeticiones.insertar(pet);
                   if (insertar){
                       Presupuesto pre = new Presupuesto();
                       pre.setIdPresupuesto(BDPeticiones.obtener(pet.getCliente().getDni(), pet.getFecha()).getIdPeticion());
                       idTarea = pre.getIdPresupuesto();
                       pre.setFecha(new GregorianCalendar());
                       pre.setIdTecnicoResponsable(this.usuario.getId());
                       pre.aceptar();
                       ArrayList<Servicio> spre = new ArrayList<>(this.tablaServiciosPresupuesto.getRowCount());
                       for (int i = 0; i < this.tablaServiciosPresupuesto.getRowCount();i++){
                           Servicio temp = BDServicios.buscar(BDServicios.buscarPorNombre,((String)tablaServiciosPresupuesto.getValueAt(i, 0)) , BDServicios.ASC, false)[0];
                           temp.setUnidades((int)tablaServiciosPresupuesto.getValueAt(i, 1));
                           spre.add(temp);
                       }
                       pre.setServiciosEstimados(spre.toArray(new Servicio[0]));

                       boolean insertarPre = BDPresupuestos.insertar(pre);
                       if (insertarPre){
                           this.dialogoNuevaPeticion.setVisible(false);
                           this.dialogoNuevaPeticion.dispose();
                           this.limpiarPeticion();
                           //Mostrar el siguiente dialogo
                           prepararRecogida(true);
                           this.dialogoREquipos.pack();
                           this.dialogoREquipos.setLocationRelativeTo(null);
                           this.dialogoREquipos.setVisible(true);
                           this.tablaEquipos.setModel(new AlmacenDefaultTableModel(false));
                           this.comboTecnicos.setModel(new OcupacionSearchModel(comboTecnicos,BDTecnicos.obtenerTodos()));
                           this.tablaPeticiones.setModel(new PeticionesDefaultTableModel(false, BDPeticiones.buscar(BDPeticiones.buscarPorFecha, ConversorFecha.getFechaFormatoBD(new GregorianCalendar()))));
                           this.tablaTareas.setModel(new TareasDefaultTableModel(false,BDTareas.obtenerTodos()));
                           isFirst3 = true;
                           filaEditada = -1;
                       } else {
                           //mensaje error al insertar
                           Dialogos.mostrarDialogoInformacion("Error al insertar los datos en la base de datos.");
                       }
                   } else {
                       //mensaje error al insertar 
                       Dialogos.mostrarDialogoInformacion("Error al insertar los datos en la base de datos.");
                   }
               }
           }else{
               Dialogos.mostrarDialogoInformacion("No se ha rellenado el presupuesto.");
           }
       }else{
       //Mostrar mensaje rellenar descripcion
       Dialogos.mostrarDialogoInformacion("No se ha rellenado la descripción de la peticion.");
       }
    }//GEN-LAST:event_btnAceptarNPeticionActionPerformed

    private void comboTecnicosPopupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {//GEN-FIRST:event_comboTecnicosPopupMenuWillBecomeVisible
        // TODO add your handling code here:
        if (isFirst3 && (comboTecnicos.getModel() != null)) {
            isFirst3 = false;
            ((OcupacionSearchModel)comboTecnicos.getModel()).updateModel("");
        }
    }//GEN-LAST:event_comboTecnicosPopupMenuWillBecomeVisible

    private void btnAñadirEquipoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAñadirEquipoActionPerformed
        // TODO add your handling code here:
        AlmacenDefaultTableModel modelo = (AlmacenDefaultTableModel) this.tablaEquipos.getModel();
        if (filaEditada ==-1){
            Equipo temp = new Equipo();
        temp.setMarca(txtMarca.getText());
        temp.setModelo(txtModelo.getText());
        temp.setNumeroSerie(txtNumeroSerie.getText());
        modelo.añadirFila(temp);
        }else {
            modelo.setValueAt(txtNumeroSerie.getText(),filaEditada, 0);
            modelo.setValueAt(txtMarca.getText(), filaEditada, 1);
            modelo.setValueAt(txtModelo.getText(), filaEditada,2);
            filaEditada = -1;
        }
        this.tablaEquipos.setModel(modelo);
        limpiarVEquipos();
    }//GEN-LAST:event_btnAñadirEquipoActionPerformed
    private void limpiarVEquipos(){
        txtMarca.setText("");
        txtModelo.setText("");
        txtNumeroSerie.setText("");
    }
    private void btnQuitarEquipoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarEquipoActionPerformed
        // TODO add your handling code here:
        int fila = this.tablaEquipos.getSelectedRow();
        if (fila != -1){
            AlmacenDefaultTableModel modelo = (AlmacenDefaultTableModel) this.tablaEquipos.getModel();
            modelo.removeRow(fila);
            this.tablaEquipos.setModel(modelo);
        } else {
            Dialogos.mostrarDialogoNoElemento();
        }
    }//GEN-LAST:event_btnQuitarEquipoActionPerformed

    private void btnEditarEquipoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarEquipoActionPerformed
        // TODO add your handling code here:
        int fila = this.tablaEquipos.getSelectedRow();
        if (fila != -1){
            filaEditada = fila;
            AlmacenDefaultTableModel modelo = (AlmacenDefaultTableModel) this.tablaEquipos.getModel();
            txtNumeroSerie.setText((String)modelo.getValueAt(fila,0));
            txtMarca.setText((String)modelo.getValueAt(fila, 1));
            txtModelo.setText((String)modelo.getValueAt(fila,2));
            this.tablaEquipos.setModel(modelo);
        } else {
            Dialogos.mostrarDialogoNoElemento();
        }
    }//GEN-LAST:event_btnEditarEquipoActionPerformed

    private void btnCancelarRecogidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarRecogidaActionPerformed
        // TODO add your handling code here:
        this.dialogoREquipos.setVisible(false);
        this.dialogoREquipos.dispose();
    }//GEN-LAST:event_btnCancelarRecogidaActionPerformed

    private void btnAceptarRecogidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarRecogidaActionPerformed
        // TODO add your handling code here:
        if (this.tablaEquipos.getRowCount() != 0 && this.comboTecnicos.getSelectedIndex() != -1){
            Tarea temp = new Tarea();
            temp.setIdTarea(idTarea);
            temp.setEstado(Estado.PENDIENTE);
            temp.setPrioridad(5);
            //Recuperar empleados del combo
            String combo = (String)comboTecnicos.getSelectedItem();
            int index = combo.indexOf(" ");
            int id = Integer.parseInt(combo.substring(0, index));
            temp.setIdEmpleado(new int[]{id});
            if (BDTareas.insertar(temp)){
                AlmacenDefaultTableModel modelo = (AlmacenDefaultTableModel) this.tablaEquipos.getModel();
                boolean error = false;
                for (int i = 0; i < this.tablaEquipos.getRowCount();i++){
                    Equipo e = new Equipo();
                    e.setNumeroSerie((String)modelo.getValueAt(i,0));
                    e.setMarca((String)modelo.getValueAt(i, 1));
                    e.setModelo((String)modelo.getValueAt(i,2));
                    e.setIdTarea(idTarea);
                    e.setFechaRecogida(new GregorianCalendar());
                    if (!BDAlmacenEquipos.insertar(e)){
                        error = true;
                    }
                }
                if (error){
                    //Se ha producido un error
                    Dialogos.mostrarDialogoInformacion("Error al insertar los datos en la base de datos.");
                } else {
                    //Terminado correctamente
                    this.tablaPeticiones.setModel(new PeticionesDefaultTableModel(false, BDPeticiones.buscar(BDPeticiones.buscarPorFecha, ConversorFecha.getFechaFormatoBD(new GregorianCalendar()))));
                this.tablaTareas.setModel(new TareasDefaultTableModel(false,BDTareas.obtenerTodos()));
                    this.dialogoREquipos.setVisible(false);
                    this.limpiarVEquipos();
                    this.dialogoREquipos.dispose();
                    
                    Dialogos.mostrarDialogoInformacion("Añadido correctamente!.");
                }
            }else {
                Dialogos.mostrarDialogoInformacion("Error al insertar los datos en la base de datos.");
            }
        } else {
            Dialogos.mostrarDialogoInformacion("Se debe añadir al menos un equipo y seleccionar un técnico.");
        }
    }//GEN-LAST:event_btnAceptarRecogidaActionPerformed

    private void tablaPeticionesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaPeticionesMouseClicked
        // TODO add your handling code here:
        int fila = this.tablaPeticiones.getSelectedRow();
        if (fila != -1){
            long idPeticion = (long) this.tablaPeticiones.getValueAt(fila, 1);
            if (BDTareas.existe(idPeticion)){
                //Mostrar información de tarea.
                this.idTarea = idPeticion;
                prepararRecogida(false);
                this.dialogoREquipos.pack();
               this.dialogoREquipos.setLocationRelativeTo(null);
               this.dialogoREquipos.setVisible(true);
               this.tablaEquipos.setModel(new AlmacenDefaultTableModel(false,BDAlmacenEquipos.buscar(BDAlmacenEquipos.buscarPorIdTarea, idTarea+"", BDAlmacenEquipos.ASC, true)));
               this.comboTecnicos.setModel(new DefaultComboBoxModel());
               Empleado temp = BDTecnicos.obtenerParticipanTarea(idTarea)[0];
               String s = temp.getIdEmpleado() + " " + temp.getNombre() + " "+ (BDTareas.obtenerNumeroTareasTecnico(temp.getIdEmpleado()));
               this.comboTecnicos.setSelectedItem(s);
            }else{
                prepararRecogida(true);
                this.idTarea = idPeticion;
                this.dialogoREquipos.pack();
               this.dialogoREquipos.setLocationRelativeTo(null);
               this.dialogoREquipos.setVisible(true);
               this.tablaEquipos.setModel(new AlmacenDefaultTableModel(false));
               this.comboTecnicos.setModel(new OcupacionSearchModel(comboTecnicos,BDTecnicos.obtenerTodos()));
               isFirst3 = true;
               filaEditada = -1;
            }
        }  
    }//GEN-LAST:event_tablaPeticionesMouseClicked

    private void txtBuscarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtBuscarKeyReleased
        // TODO add your handling code here:
        if (Character.isWhitespace(evt.getKeyChar())){
            evt.consume();
        } else {
            if (txtBuscar.getText().isEmpty()){
                this.tablaPeticiones.setModel(new PeticionesDefaultTableModel(false, BDPeticiones.buscar(BDPeticiones.buscarPorFecha, ConversorFecha.getFechaFormatoBD(new GregorianCalendar()))));
                this.tablaTareas.setModel(new TareasDefaultTableModel(false,BDTareas.obtenerTodos()));
            } else {
               this.tablaPeticiones.setModel(new PeticionesDefaultTableModel(false, BDPeticiones.buscar(BDPeticiones.buscarPorDNI,txtBuscar.getText())));
               this.tablaTareas.setModel(new TareasDefaultTableModel(false, BDTareas.buscarPorDNI(txtBuscar.getText())));
            }
         }
    }//GEN-LAST:event_txtBuscarKeyReleased

    private void tablaTareasMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaTareasMouseClicked
        // TODO add your handling code here:
        if (evt.getClickCount() == 2){
            int fila = this.tablaTareas.getSelectedRow();
            if (fila != -1){
                long id = (long) this.tablaTareas.getValueAt(fila, 1);
                String estado =(String) this.tablaTareas.getValueAt(fila, 2);
                if ("FINALIZADO".equals(estado)){
                    this.dialogoTarea.pack();
                    this.dialogoTarea.setVisible(true);
                    this.dialogoTarea.setLocationRelativeTo(null);
                    Cliente cliente =(BDPeticiones.obtener(id)).getCliente();
                    lblNombre3.setText(cliente.getNombre() + " "+ (cliente.getPrimerApellido()==null?" ":cliente.getPrimerApellido()) + " " + (cliente.getSegundoApellido()==null?" ":cliente.getSegundoApellido()));
                    lblDireccion3.setText(cliente.getDireccion()==null?"Sin dirección":cliente.getDireccion().toString());
                    this.listaTelefonos3.setModel(new TelefonosDefaultListModel(cliente.getTelefonos()));
                    this.tablaServiciosPrestados.setModel(new ServiciosPrestadosDefaultTableModel(false,BDServicios.obtenerPrestados(id)));
                    equiposADevolver = BDAlmacenEquipos.buscar(BDAlmacenEquipos.buscarPorIdTarea, id+"", BDAlmacenEquipos.ASC, true);
                    this.tablaEquiposDevolver.setModel(new AlmacenDefaultTableModel(false,equiposADevolver,false));
                    if (this.tablaEquiposDevolver.getRowCount() == 0){
                        this.tablaEquiposDevolver.setEnabled(false);
                        DefaultTableModel d = new DefaultTableModel();
                        d.addColumn("");
                        d.addRow(new Object[]{"Todos los equipos han sido devueltos."});
                        this.tablaEquiposDevolver.setModel(d);
                        this.btnDevolver.setEnabled(false);
                    } else {
                        this.tablaEquiposDevolver.setEnabled(true);
                        this.btnDevolver.setEnabled(true);
                    }
                    this.total.setText(((ServiciosPrestadosDefaultTableModel) tablaServiciosPrestados.getModel()).calcularCoste()+ " €");
                } 
            }
        }
    }//GEN-LAST:event_tablaTareasMouseClicked

    private void btnDevolverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDevolverActionPerformed
        // TODO add your handling code here:
        if (equiposADevolver != null){
            boolean error = false;
            for (Equipo temp : equiposADevolver){
                temp.setFechaRecogida(new GregorianCalendar());
                boolean actualizar = BDAlmacenEquipos.actualizar(temp);
                if (!actualizar){
                    error = true;
                }
            }
            if (error){
                //Mensaje de fallo de devolucion
                Dialogos.mostrarDialogoInformacion("Error al registrar la devolución de los equipos.");
            } else {
                //Mensaje devueltos correctamente
                Dialogos.mostrarDialogoInformacion("Equipos devueltos correctamente!.");
                this.tablaEquiposDevolver.setEnabled(false);
                DefaultTableModel d = new DefaultTableModel();
                d.addColumn("");
                d.addRow(new Object[]{"Todos los equipos han sido devueltos."});
                this.tablaEquiposDevolver.setModel(d);
                this.btnDevolver.setEnabled(false);
            }
        }
    }//GEN-LAST:event_btnDevolverActionPerformed

    private void btnCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCerrarActionPerformed
        // TODO add your handling code here:
        this.dialogoTarea.pack();
        this.dialogoTarea.setVisible(false);
        this.dialogoTarea.setLocationRelativeTo(null);
        limpiarDialogoTarea();
    }//GEN-LAST:event_btnCerrarActionPerformed

    private void listaAvisosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listaAvisosMouseClicked
        // TODO add your handling code here:
        if (evt.getClickCount() == 2){
            //Mostrar dialogo aviso para el aviso seleccionado.
            int selectedIndex = this.listaAvisos.getSelectedIndex();
            if (selectedIndex != -1){
                //Rellenar campos
                AvisosDefaultListModel mod = (AvisosDefaultListModel) this.listaAvisos.getModel();
                Cliente c = mod.obtenerCliente(selectedIndex);
                a = mod.obtenerAviso(selectedIndex);
                idTareaAviso = a.getIdTarea();
                if (BDTareas.obtener(idTareaAviso).getEstado() == Estado.ECONFIRMACION){
                Presupuesto[] presupuestos = BDPresupuestos.obtenerPresupuestosDESC(a.getIdTarea());
                lblNombreClienteAviso.setText(c.getNombre() + "  " + (c.getPrimerApellido()==null?"":c.getPrimerApellido()));
                String telefonos = "";
                for (Telefono temp : c.getTelefonos()){
                    telefonos += "\t " + temp.getNumero();
                }
                lblTelefonoClienteAviso.setText(telefonos);
                tablaPreAntiguo.setModel(new ServiciosPrestadosDefaultTableModel(false, presupuestos[1].getServiciosEstimados()));
                tablaPreNuevo.setModel(new ServiciosPrestadosDefaultTableModel(false, presupuestos[0].getServiciosEstimados()));
                txtDesAviso.setText(a.getDescripcion());
                //Mostrar dialogo mostrar aviso
                this.verAvisos.pack();
                this.verAvisos.setLocationRelativeTo(null);
                this.verAvisos.setVisible(true);
                } else {
                    //Mostrar cuadro finalizada
                    lblNombreClienteAviso1.setText(c.getNombre() + "  " + (c.getPrimerApellido()==null?"":c.getPrimerApellido()));
                    String telefonos = "";
                    for (Telefono temp : c.getTelefonos()){
                        telefonos += "\t " + temp.getNumero();
                    }
                    lblTelefonoClienteAviso1.setText(telefonos);
                    txtDesAviso1.setText(a.getDescripcion());
                    this.verAvisoFinalizado.pack();
                    this.verAvisoFinalizado.setLocationRelativeTo(null);
                    this.verAvisoFinalizado.setVisible(true);
                }
            }
        }
    }//GEN-LAST:event_listaAvisosMouseClicked

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        this.limpiarDialogoAviso();
        this.verAvisos.setVisible(false);
    }//GEN-LAST:event_jButton5ActionPerformed

    private void btnAceptarModificacionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarModificacionesActionPerformed
       Tarea t = BDTareas.obtener(idTareaAviso);
       t.setEstado(Estado.PENDIENTE);
       if(BDTareas.actualizar(t)){
           Dialogos.mostrarDialogoInformacion("Modificado correctamente.");
       } else {
           Dialogos.mostrarDialogoInformacion("No se han podido salvar los cambios.");
       }
       a.notificar();
       BDAviso.actualizar(a);
       tablaPeticiones.setModel(new PeticionesDefaultTableModel(false, BDPeticiones.buscar(BDPeticiones.buscarPorFecha, ConversorFecha.getFechaFormatoBD(new GregorianCalendar()))));
        tablaTareas.setModel(new TareasDefaultTableModel(false,BDTareas.obtenerTodos()));
       actualizarListadoAvisos();
       this.limpiarDialogoAviso();
        this.verAvisos.setVisible(false);
    }//GEN-LAST:event_btnAceptarModificacionesActionPerformed

    private void btnCancelarModificacionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarModificacionesActionPerformed
       Tarea t = BDTareas.obtener(idTareaAviso);
       t.setEstado(Estado.FINALIZADO);
       if(BDTareas.actualizar(t)){
           Dialogos.mostrarDialogoInformacion("Modificado correctamente.");
       } else {
           Dialogos.mostrarDialogoInformacion("No se han podido salvar los cambios.");
       }
       //Generar factura?
       a.notificar();
       BDAviso.actualizar(a);
       tablaPeticiones.setModel(new PeticionesDefaultTableModel(false, BDPeticiones.buscar(BDPeticiones.buscarPorFecha, ConversorFecha.getFechaFormatoBD(new GregorianCalendar()))));
        tablaTareas.setModel(new TareasDefaultTableModel(false,BDTareas.obtenerTodos()));
       actualizarListadoAvisos();
       this.limpiarDialogoAviso();
        this.verAvisos.setVisible(false);
    }//GEN-LAST:event_btnCancelarModificacionesActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        VerPresupuesto v = new VerPresupuesto(this.idTareaAviso);
        v.setLocationRelativeTo(null);
        v.setVisible(true);
    }//GEN-LAST:event_jButton3ActionPerformed

    private void btnNoNotificadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNoNotificadoActionPerformed
        this.verAvisoFinalizado.setVisible(false);
    }//GEN-LAST:event_btnNoNotificadoActionPerformed

    private void btnNotificadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNotificadoActionPerformed
        Tarea t = BDTareas.obtener(idTareaAviso);
       if(BDTareas.actualizar(t)){
           a.notificar();
           BDAviso.actualizar(a);
           tablaPeticiones.setModel(new PeticionesDefaultTableModel(false, BDPeticiones.buscar(BDPeticiones.buscarPorFecha, ConversorFecha.getFechaFormatoBD(new GregorianCalendar()))));
            tablaTareas.setModel(new TareasDefaultTableModel(false,BDTareas.obtenerTodos()));
           actualizarListadoAvisos();
           Dialogos.mostrarDialogoInformacion("Notificación almacenada");
           this.verAvisoFinalizado.setVisible(false);
           this.verAvisoFinalizado.dispose();
       } else {
           Dialogos.mostrarDialogoInformacion("No se ha registrado la notificación.");
       }

    }//GEN-LAST:event_btnNotificadoActionPerformed

    private void btnEditarClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditarClienteActionPerformed
        // TODO add your handling code here:
        if (clienteActual != null){
            AñadirCliente ac = new AñadirCliente(clienteActual);
            ac.setVisible(true);
        }
    }//GEN-LAST:event_btnEditarClienteActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        mostrarDialogoNuevaPeticion();
    }//GEN-LAST:event_jButton4ActionPerformed
    public void limpiarDialogoAviso(){
        lblNombreClienteAviso.setText("");
        lblTelefonoClienteAviso.setText("");
        tablaPreAntiguo.setModel(new ServiciosPrestadosDefaultTableModel(false));
        tablaPreNuevo.setModel(new ServiciosPrestadosDefaultTableModel(false));
        txtDesAviso.setText("");
    }
    public void limpiarDialogoTarea(){
        lblNombre3.setText("");
        lblDireccion3.setText("");
        this.listaTelefonos3.setModel(new DefaultListModel());
        this.tablaServiciosPrestados.setModel(new ServiciosPrestadosDefaultTableModel(false));
        this.tablaEquiposDevolver.setModel(new AlmacenDefaultTableModel(false));
        this.total.setText("");
    }
    public void prepararRecogida(boolean estado){
        this.txtNumeroSerie.setEnabled(estado);
        this.txtMarca.setEnabled(estado);
        this.txtModelo.setEnabled(estado);
        this.comboTecnicos.setEnabled(estado);
        this.btnAñadirEquipo.setEnabled(estado);
        this.btnEditarEquipo.setEnabled(estado);
        this.btnQuitarEquipo.setEnabled(estado);
        this.btnAceptarRecogida.setVisible(estado);
        //si el estado es falso cambiar los botones para evitar acciones incorrectas
        if (!estado){//Si es falso
            this.btnCancelarRecogida.setText("Cerrar");
        } else {
            this.btnCancelarRecogida.setText("Cancelar");
        }
    }
    public void limpiarPeticion(){
        lblNombre.setText("");
        lblDireccion.setText("");
        listaTelefonos.setModel(new DefaultListModel());
        txtDescripcion.setText("");
        lblTotal.setText("");
        unidades.setValue(1);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VistaRecepcionista.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VistaRecepcionista.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VistaRecepcionista.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VistaRecepcionista.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form 
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VistaRecepcionista().setVisible(true);
            }
        });*/
    }
    private class AvisosDefaultListModel extends DefaultListModel{
        private ArrayList<Aviso> avisos = new ArrayList<>(0);
        private ArrayList<Cliente> clientes = new ArrayList<>(0);
        public AvisosDefaultListModel(){
            for (Aviso temp : BDAviso.buscar(BDAviso.buscarPorFecha, "", BDAviso.DESC, false)){
                //Si no esta notificado entonces añadir al listado
                if (!temp.isNotificado()){
                    avisos.add(temp);
                    Cliente cliente = BDClientes.obtenerCliente(BDPeticiones.obtener(temp.getIdTarea()).getCliente().getDni());
                    clientes.add(cliente);
                    this.addElement(ConversorFecha.formateadorFecha(temp.getFecha()) + " "+ cliente.getNombre() + " " + ((cliente.getPrimerApellido()==null)?"":cliente.getPrimerApellido()));
                }
            }
        }
        public Aviso obtenerAviso(int id){
            Aviso a;
            try {
                a = avisos.get(id);
            } catch (IndexOutOfBoundsException e){
                a = null;
            }
            return a;
        }
        public Cliente obtenerCliente(int id){
            Cliente c;
            try {
                c = clientes.get(id);
            } catch (IndexOutOfBoundsException e){
                c = null;
            }return c;
        }
    }
    private class TelefonosDefaultListModel extends DefaultListModel{
        public TelefonosDefaultListModel(Telefono[] telefonos){
            if (telefonos != null){
            for (Telefono temp : telefonos){
                    this.addElement(temp.getNumero());
            }}
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAceptarModificaciones;
    private javax.swing.JButton btnAceptarNPeticion;
    private javax.swing.JButton btnAceptarRecogida;
    private javax.swing.JButton btnAñadirEquipo;
    private javax.swing.JButton btnAñadirNuevoCliente;
    private javax.swing.JButton btnAñadirPresupuesto;
    private javax.swing.JButton btnCancelarModificaciones;
    private javax.swing.JButton btnCancelarNPeticion;
    private javax.swing.JButton btnCancelarRecogida;
    private javax.swing.JButton btnCerrar;
    private javax.swing.JButton btnDevolver;
    private javax.swing.JButton btnEditarCliente;
    private javax.swing.JButton btnEditarEquipo;
    private javax.swing.JButton btnFactura;
    private javax.swing.JButton btnNoNotificado;
    private javax.swing.JButton btnNotificado;
    private javax.swing.JButton btnQuitarEquipo;
    private static javax.swing.JComboBox comboClientes;
    private javax.swing.JComboBox comboServicios;
    private javax.swing.JComboBox comboTecnicos;
    private javax.swing.JDialog dialogoNuevaPeticion;
    private javax.swing.JDialog dialogoREquipos;
    private javax.swing.JDialog dialogoTarea;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JDialog jDialog1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel16;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel19;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel20;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JPanel jPanel24;
    private javax.swing.JPanel jPanel25;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane11;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JScrollPane jScrollPane13;
    private javax.swing.JScrollPane jScrollPane14;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lblDireccion;
    private javax.swing.JLabel lblDireccion3;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblNombre3;
    private javax.swing.JLabel lblNombreClienteAviso;
    private javax.swing.JLabel lblNombreClienteAviso1;
    private javax.swing.JLabel lblTelefonoClienteAviso;
    private javax.swing.JLabel lblTelefonoClienteAviso1;
    private javax.swing.JLabel lblTotal;
    private javax.swing.JList listaAvisos;
    private javax.swing.JList listaTelefonos;
    private javax.swing.JList listaTelefonos3;
    private javax.swing.JMenuItem mnuBorrarFila;
    private javax.swing.JMenuItem mnuBorrarUnidades;
    private javax.swing.JPanel panelAvisos;
    private javax.swing.JPanel panelPeticiones;
    private javax.swing.JPanel panelPeticiones1;
    private javax.swing.JPanel panelTareas;
    private javax.swing.JPanel panelTareas1;
    private javax.swing.JPopupMenu popupPresupuesto;
    private javax.swing.JTable tablaEquipos;
    private javax.swing.JTable tablaEquiposDevolver;
    private javax.swing.JTable tablaPeticiones;
    private javax.swing.JTable tablaPreAntiguo;
    private javax.swing.JTable tablaPreNuevo;
    private javax.swing.JTable tablaServiciosPrestados;
    private javax.swing.JTable tablaServiciosPresupuesto;
    private javax.swing.JTable tablaTareas;
    private javax.swing.JLabel total;
    private javax.swing.JTextField txtBuscar;
    private javax.swing.JTextArea txtDesAviso;
    private javax.swing.JTextArea txtDesAviso1;
    private javax.swing.JTextArea txtDescripcion;
    private javax.swing.JTextField txtMarca;
    private javax.swing.JTextField txtModelo;
    private javax.swing.JTextField txtNumeroSerie;
    private javax.swing.JSpinner unidades;
    private javax.swing.JDialog verAvisoFinalizado;
    private javax.swing.JDialog verAvisos;
    // End of variables declaration//GEN-END:variables
}
